package com.jlnk.androidfmc;

import android.os.Bundle;
import android.widget.ImageButton;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.jlnk.androidfmc.adapter.FootAdapter;
import com.jlnk.androidfmc.entity.FootItem;
import java.util.ArrayList;
import java.util.List;

public class FootActivity extends AppCompatActivity {
    private RecyclerView recyclerViewFoot;
    private List<FootItem> footList = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_foot); // 使用您提供的XML布局文件

        recyclerViewFoot = findViewById(R.id.recyclerViewFoot);
        recyclerViewFoot.setLayoutManager(new LinearLayoutManager(this));

        // 初始化数据列表，这里只是示例数据
        footList.add(new FootItem("牛奶", 10.0, R.drawable.nn));
        footList.add(new FootItem("牛肉", 90.0, R.drawable.nr));
        footList.add(new FootItem("白菜", 12.1, R.drawable.bc));
        footList.add(new FootItem("西兰花", 9.4, R.drawable.xlh));
        // ... 添加更多数据

        // 创建适配器并设置给RecyclerView
        FootAdapter adapter = new FootAdapter(footList);
        recyclerViewFoot.setAdapter(adapter);

        // 在FootActivity的onCreate方法中初始化返回按钮并设置点击事件
        ImageButton backButton = findViewById(R.id.button_back);
        backButton.setOnClickListener(v -> {
            finish(); // 结束当前Activity，返回到上一个Activity
        });
    }
}